package com.lshj.impl;

import com.alibaba.fastjson.JSON;
import com.hj.lib.entity.AjaxJson;
import com.hj.lib.impl.HjTioHandle;
import com.hj.lib.util.LogUtil;
import com.lshj.QmMain;
import javafx.application.Platform;
import sun.applet.Main;

public class HjTioImpl  implements HjTioHandle {
	public void onMessage(final AjaxJson ajaxJson) {
		//签名完成，退出会议，退出签名
		if (ajaxJson.getCode() == (AjaxJson.HjTioCode.TZRH)|| ajaxJson.getCode() == (AjaxJson.HjTioCode.QMWC) || ajaxJson.getCode() == (AjaxJson.HjTioCode.TCHY) ||  ajaxJson.getCode() == (AjaxJson.HjTioCode.TCQM)) {

			Platform.runLater(new Runnable() {
				public void run() {
					QmMain.primaryStage.setMaximized(true);
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					QmMain.primaryStage.setIconified(true);
				}
			});

		}
		if (ajaxJson.getCode() == AjaxJson.HjTioCode.FQQM) {
			if (ajaxJson.getObj() != null) {

				Platform.runLater(new Runnable() {
					public void run() {
						LogUtil.debug("qm","收到发起签名的信息");
						try {
							QmMain.primaryStage.setIconified(true);
							QmMain.browser.loadURL(ajaxJson.getObj().toString());
							QmMain.primaryStage.setMaximized(true);
						} catch (Exception e) {
							e.printStackTrace();
							LogUtil.debug("qm","调起签名报错");
						}
					}
				});


			} else {
				LogUtil.debug("qm","签名url 为空");
			}
		}else {

		}
	}
}
